package a.j;

import a.c.d;
import a.c.e;

import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

public class of
  extends gf
{
  private e m;
  private boolean G = true;
  private boolean H = false;
  private boolean I = true;
  private boolean J = false;
  private KeyListener K;
  private int L = 27;
  private b_ M = new b_();
  private e N;
  private e O;
  private d P;
  private boolean Q = false;
  public static int R;
  
  public of(df paramdf)
  {
    super(paramdf);
  }
  
  public of() {}
  
  public void f()
  {
    this.G = true;
  }
  
  public void g(boolean paramBoolean)
  {
    this.I = paramBoolean;
  }
  
  public boolean v()
  {
    return this.I;
  }
  
  public void mousePressedLeft(double paramDouble1, double paramDouble2)
  {
    this.J = true;
    b(paramDouble1, paramDouble2, false);
  }
  
  public void mouseShiftPressedLeft(double paramDouble1, double paramDouble2)
  {
    this.J = true;
    b(paramDouble1, paramDouble2, true);
  }
  
  void b(double paramDouble1, double paramDouble2, boolean paramBoolean)
  {
    boolean bool = ld.E;
    if ((bool) || (this.G))
    {
      g localg = k();
      this.m = a(paramDouble1, paramDouble2).m();
      if (!bool) {
        if (this.m == null) {
          return;
        }
      }
      if (!bool) {
        if (!acceptSourceNode(this.m, paramDouble1, paramDouble2))
        {
          sourceNodeDeclined(this.m, paramDouble1, paramDouble2);
          return;
        }
      }
      if (!bool)
      {
        if (this.K == null)
        {
          if (bool) {
            break label251;
          }
          if (this.L >= 0)
          {
            this.K = new KeyListener()
            {
              public void keyTyped(KeyEvent paramAnonymousKeyEvent) {}
              
              public void keyPressed(KeyEvent paramAnonymousKeyEvent) {}
              
              public void keyReleased(KeyEvent paramAnonymousKeyEvent)
              {
                boolean bool = ld.E;
                if (!bool)
                {
                  if (!of.this.J)
                  {
                    if (bool) {
                      break label68;
                    }
                    if (of.this.Q)
                    {
                      if (bool) {
                        break label68;
                      }
                      if (paramAnonymousKeyEvent.getKeyCode() == of.this.L) {
                        of.this.B();
                      }
                    }
                  }
                  if (bool) {
                    break label86;
                  }
                }
                if (!of.this.Q)
                {
                  label68:
                  of.this.i.removeKeyListener(this);
                  label86:
                  of.this.K = null;
                }
              }
            };
            this.i.B().addKeyListener(this.K);
          }
        }
        this.M.o();
        this.i.a(this.M);
        a(true);
        this.O = this.M.a(a(localg.w(this.m)));
        this.N = this.M.a(b(paramDouble1, paramDouble2));
        this.P = this.M.a(this.O, this.N, x());
        this.H = true;
        localg.b((byte)1);
        this.i.e(3);
        this.G = false;
      }
      else
      {
        if (bool) {
          break label255;
        }
        this.Q = true;
      }
      if (paramBoolean)
      {
        label251:
        label255:
        ld localld = this.M.w(this.O);
        double d1 = a(paramDouble1) - localld.A();
        double d2 = b(paramDouble2) - localld.B();
        this.M.t(this.P).k().b(d1, d2);
      }
    }
  }
  
  protected ld w()
  {
    ld localld = k().M().m();
    localld.b(Integer.toString(k().j() + 1));
    return localld;
  }
  
  protected tb x()
  {
    return k().O().e();
  }
  
  protected tb y()
  {
    boolean bool = ld.E;
    if ((bool) || (this.M != null))
    {
      if (bool) {
        break label44;
      }
      if (this.M.l() >= 1) {}
    }
    else
    {
      throw new IllegalStateException("EdgeRealizer not yet created!");
    }
    label44:
    return this.M.t(this.P);
  }
  
  protected ld a(ld paramld)
  {
    return paramld.m();
  }
  
  protected ld b(double paramDouble1, double paramDouble2)
  {
    od localod = new od();
    localod.b(0.0D, 0.0D);
    localod.c(paramDouble1, paramDouble2);
    localod.b((byte)0);
    localod.d(false);
    return localod;
  }
  
  protected ld z()
  {
    boolean bool = ld.E;
    if ((bool) || (this.M != null))
    {
      if (bool) {
        break label44;
      }
      if (this.M.l() >= 1) {}
    }
    else
    {
      throw new IllegalStateException("Edge not yet created!");
    }
    label44:
    return this.M.w(this.P.f());
  }
  
  protected ld A()
  {
    boolean bool = ld.E;
    if ((bool) || (this.M != null))
    {
      if (bool) {
        break label44;
      }
      if (this.M.l() >= 1) {}
    }
    else
    {
      throw new IllegalStateException("Edge not yet created!");
    }
    label44:
    return this.M.w(this.P.e());
  }
  
  public void mouseReleasedRight(double paramDouble1, double paramDouble2)
  {
    boolean bool = ld.E;
    this.J = false;
    if (!bool) {
      if (!this.Q) {
        return;
      }
    }
    g localg = k();
    tb localtb = this.M.t(this.P);
    int i = localtb.n();
    if (!bool) {
      if (i > localtb.r())
      {
        localtb.a(localtb.b(i - 1));
        this.i.b();
        if (!bool) {
          if (!ld.D) {
            return;
          }
        }
      }
      else
      {
        B();
        a(false);
        localg.gb();
      }
    }
    g();
  }
  
  public void mouseShiftReleasedLeft(double paramDouble1, double paramDouble2)
  {
    this.J = false;
    c(paramDouble1, paramDouble2, true);
  }
  
  public void mouseReleasedLeft(double paramDouble1, double paramDouble2)
  {
    this.J = false;
    c(paramDouble1, paramDouble2, false);
  }
  
  void c(double paramDouble1, double paramDouble2, boolean paramBoolean)
  {
    boolean bool = ld.E;
    if (!bool) {
      if (!this.Q) {
        return;
      }
    }
    double d1 = a(paramDouble1);
    double d2 = b(paramDouble2);
    g localg = k();
    tb localtb = this.M.t(this.P);
    ld localld = w();
    if (!bool) {
      if ((paramBoolean) && ((bool) || (acceptBend(this.m, paramDouble1, paramDouble2))))
      {
        if (!bool)
        {
          if (!this.I) {
            return;
          }
          localtb.c(d1, d2);
          if (bool) {}
        }
        else if (!ld.D)
        {
          return;
        }
      }
      else {
        localld.c(d1, d2);
      }
    }
    e locale = localg.a(localld);
    a(locale);
    d locald = localg.a(this.m, locale, localtb);
    localg.b((byte)0);
    this.i.e(0);
    this.i.b(this.M);
    edgeCreated(locald);
    a(false);
    localg.gb();
    g();
  }
  
  protected boolean acceptBend(e parame, double paramDouble1, double paramDouble2)
  {
    return this.I;
  }
  
  public void mouseDraggedLeft(double paramDouble1, double paramDouble2)
  {
    if (!ld.E)
    {
      if (!this.Q) {
        return;
      }
      paramDouble1 = a(paramDouble1);
      paramDouble2 = b(paramDouble2);
      this.M.w(this.N).c(paramDouble1, paramDouble2);
      edgeMoved(paramDouble1, paramDouble2);
    }
    this.i.b();
  }
  
  public void mouseMoved(double paramDouble1, double paramDouble2)
  {
    mouseDraggedLeft(paramDouble1, paramDouble2);
  }
  
  public void g()
  {
    if (!ld.E)
    {
      if (this.K != null)
      {
        this.i.B().removeKeyListener(this.K);
        this.K = null;
      }
      this.Q = false;
      this.G = true;
    }
    super.g();
  }
  
  protected void edgeMoved(double paramDouble1, double paramDouble2) {}
  
  protected void edgeCreated(d paramd) {}
  
  protected void a(e parame) {}
  
  protected void B()
  {
    this.M.o();
    this.H = false;
    if (!ld.E)
    {
      if (this.K != null)
      {
        this.i.B().removeKeyListener(this.K);
        this.K = null;
      }
      k().b((byte)0);
      this.i.e(0);
      this.i.b(this.M);
      this.i.b();
      a(false);
    }
    g();
  }
  
  protected boolean acceptSourceNode(e parame, double paramDouble1, double paramDouble2)
  {
    return true;
  }
  
  protected void sourceNodeDeclined(e parame, double paramDouble1, double paramDouble2) {}
  
  public int C()
  {
    return this.L;
  }
  
  public void d(int paramInt)
  {
    this.L = paramInt;
  }
  
  public void b()
    throws UnsupportedOperationException
  {
    if ((ld.E) || (a())) {
      B();
    }
  }
  
  static class b_
    extends g
    implements qb
  {
    public void paint(Graphics2D paramGraphics2D)
    {
      t(q()).c(paramGraphics2D);
      w(r()).e(paramGraphics2D);
    }
    
    public Rectangle getBounds()
    {
      Rectangle localRectangle = d();
      return localRectangle;
    }
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.j.of

 * JD-Core Version:    0.7.0.1

 */